<?php
class FlinkController extends Controller{
	
	public function actionAdd(){
		$model = new Links();
		if(isset($_POST['Links'])){
			$model->attributes = $_POST['Links'];
			if($model->save()){
				$this->redirect(array('list'));
			}
		}
		$this->render('add', array('model'=>$model));
	}
	
	public function actionList(){
		$model = new Links();
		$list = $model->findAllBySql("SELECT * FROM {{links}} ORDER BY links_id DESC");
		$this->render('list', array('list'=>$list));
	}
	
	public function actionEdit($links_id){
		$links_id = intval($links_id);
		if($links_id <= 0){
			$this->redirect(array('list'));
		}

		//获取信息
		$info = Links::model()->findByPk($links_id);
		if(isset($_POST['Links'])){
			$info->attributes = $_POST['Links'];
			if($info->save()){
				$this->redirect(array('list'));
			}
		}
		$this->render('edit', array('model'=>$info));
	}
	
	public function actionDelete(){
		
	}
}